package cc.telecomdigital.tdstock.testcase;

import java.text.NumberFormat;

import junit.framework.Assert;
import android.test.AndroidTestCase;

public class NumberFormatTestCase extends AndroidTestCase
{
	private NumberFormat nf;
	
   
	
	
	@Override
	protected void setUp() throws Exception
	{
		nf = NumberFormat.getInstance();
		super.setUp();
	}


	@Override
	protected void tearDown() throws Exception
	{
		nf = null;
		super.tearDown();
	}


	public void testRound() throws Throwable
	{
		nf.setMaximumFractionDigits(2);
		nf.setMinimumFractionDigits(2);
		double value = 100.357;
		Assert.assertEquals("100.36" ,nf.format(value));
	}
	
	
	public void testRound2() throws Throwable
	{
		nf.setMaximumFractionDigits(3);
		nf.setMinimumFractionDigits(3);
		double value = 100.357;
		Assert.assertEquals("100.35" ,nf.format(value).substring(0, nf.format(value).length() -1));
	}
	
	public void testRound3() throws Throwable
	{
		nf.setMaximumFractionDigits(3);
		nf.setMinimumFractionDigits(3);
		double value = 100.35;
		Assert.assertEquals("100.35" ,nf.format(value).substring(0, nf.format(value).length() -1));
	}
	
	public void testRound4() throws Throwable
	{
		nf.setMaximumFractionDigits(3);
		nf.setMinimumFractionDigits(3);
		double value = 100.3;
		Assert.assertEquals("100.30" ,nf.format(value).substring(0, nf.format(value).length() -1));
	}

	
}
